#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int
main(void)
{
	static char lastname[22];
	int n, k = 0;
	int i, j;
	static int freq[99];

	scanf("%d", &n);

	for (k = 0; k < n; k++) {
		scanf("%s %*c.%*c. %d", lastname, &i);
		freq[i - 1]++;
	}

	k = -1;

	for (i = 0; i < 99; ++i)
		if (freq[i] > k)
			k = freq[i];
	for (i = 0; i < 99; ++i)
		if (freq[i] == k)
			printf("%d\n", i + 1);

	return 0;
}
